/-app
/-app/appRoot
/-app/appRoot/importExport
PageModel.ts
dragScroll.ts
/-app/koBindingHandlers
/-app/moreDialog
body.css
flyout-branding.css
flyout.css
start.ts
status.css
tree-and-bar.css
tree-details.css
/-docs ...
/-docs/types ...
/-docs/types/text ...
/-docs/types/text/base
/-docs/types/text/css
/-docs/types/text/html
/-docs/types/text/js
/-docs/types/text/json
/-docs/types/text/less
/-docs/types/text/sass
/-docs/types/text/scrollerView ...
ScrollerModel.ts
ScrollerView.html
style.css
/-docs/types/text/scss
/-docs/types/text/ts
CodeMirror-ext.css
CodeMirrorDocHandler.ts
api.ts
load.ts
api.ts
listSubmodules.ts
load.ts
DocHost.ts
/-files
/-imports
/-imports/acorn
/-imports/codemirror
/-imports/knockout
/-imports/tern
/-imports/typescript
lib.d.ts.text
typescriptServices.js
/-imports/zip.js
/-persistence
/-typescript
/-typings
errors.js
functions.ts
index.html
try.js
x
 
21
​
22
      this._recreateLines();
23
    }
24
​
25
    docChanges(docChanges: CodeMirror.EditorChange[]) {
26
      
27
      if (this._recreateTimeout)
28
        clearTimeout(this._recreateTimeout);
29
      this._recreateTimeout = setTimeout(() => this._recreateLines(), 200);
30
      
31
    }
32
​
33
    scroll(scrollInfo: CodeMirror.ScrollInfo) {
34
      var height = scrollInfo.height;
35
      var lineCount = this._doc.lineCount();
36
      if (lineCount < this._viewLineNumber)
37
        height = Math.max(height, this._doc.getEditor().defaultTextHeight() * this._viewLineNumber);
38
      
39
      this.viewportFrom((scrollInfo.top * 100 / height) + '%');
40
      this.viewportHeight((scrollInfo.clientHeight * 100 / height) + '%');
41
      (<any>scrollInfo).maxHeight = height;
42
      this._debug = {
43
        lineCount: lineCount,
44
        heightAtLine: this._doc.getEditor().heightAtLine(lineCount - 2),
45
        defaultLineHeight: this._doc.getEditor().defaultTextHeight(),
46
        height: height,
47
        scrollInfo: scrollInfo
48
      };
49
    }
50
​
51
    bindHandlers(dragElement: HTMLElement) {
52
      addEventListener(dragElement, 'touchstart', (e: any) => { 
53
        if (!e.touches || !e.touches.length) return;
54
        var editor = this._doc.getEditor();
55
        if (!editor) return;
56
​
57
        var dbg = null;
58
​
59
        var scrollInfo = editor.getScrollInfo();
60
        if (scrollInfo.clientHeight === scrollInfo.height) return;
61
        var startTop = scrollInfo.top;
62
        var startCoord = e.touches[0].clientY;
63
        var factor = scrollInfo.clientHeight / scrollInfo.height;
64
        var move = e => {
65
          if (!e.touches || !e.touches.length) return;
66
          var editor = this._doc.getEditor();
67
          if (!editor) return;
68
​
69
          var scrollInfo = editor.getScrollInfo();
70
​
71
          var deltaY = e.touches[0].clientY - startCoord;
72
          var offset = deltaY * factor;
73
          editor.scrollTo(null, scrollInfo.top + deltaY);
74
          dbg = 'scrollY->'+ (scrollInfo.top + deltaY)+' factor:'+factor+' deltaY:'+deltaY;
75
        };
76
​
77
        var close = e => {
78
          alert(dbg);
79
          removeEventListener(window, 'touchend', close);
80
          removeEventListener(window, 'touchmove', move);
81
        };
82
​
83
        addEventListener(window, 'touchmove', move);
84
        addEventListener(window, 'touchend', close);
85
      });
86
​
87
      addEventListener(dragElement, 'mousedown', (e: MouseEvent) => {
88
        var editor = this._doc.getEditor();
89
        if (!editor) return;
90
​
91
        var dbg = null;
92
​
93
        var scrollInfo = editor.getScrollInfo();
94
        if (scrollInfo.clientHeight === scrollInfo.height) return;
95
        var startTop = scrollInfo.top;
96
        var startCoord = e.clientY;
97
        var factor = scrollInfo.clientHeight / scrollInfo.height;
98
        var move = (e: MouseEvent) => {
99
          var editor = this._doc.getEditor();
100
          if (!editor) return;
101
​
102
          var scrollInfo = editor.getScrollInfo();
103
​
104
          var deltaY = e.clientY - startCoord;
105
          var offset = deltaY * factor;
106
          editor.scrollTo(null, scrollInfo.top + deltaY);
107
          dbg = 'scrollY->' + (scrollInfo.top + deltaY) + ' factor:' + factor + ' deltaY:' + deltaY;
108
        };
109
​
110
        var close = e => {
111
          alert(dbg);
112
          removeEventListener(window, 'mouseup', close);
113
          removeEventListener(window, 'mousemove', move);
114
        };
115
​
116
        addEventListener(window, 'mousemove', move);
117
        addEventListener(window, 'mouseup', close);
118
      });
119
    }
120
​
121
    private _recreateLines() {
122
      var newLines: ScrollerModel.LineModel[] = [];
123
      
124
      var docLineCount = this._doc.lineCount();
125
      var maxLinesPerRun = (docLineCount / this._viewLineNumber) | 0;
126
      
127
      var run: string[] = [];
128
      var runLength = 0;
129
      
130
      var maxLength = 80;
131
      
132
      for (var i = 0; i < docLineCount; i++) {
133
        run[runLength] = this._doc.getLine(i);
134
        runLength++;
135
        if (runLength >= maxLinesPerRun || i === docLineCount - 1) { 
136
          if (run.length > runLength)
137
            run.length = runLength; // happens only with the last run
138
          var newLine = this._createLine(run);
139
          maxLength = Math.max(maxLength, newLine.leadLength + newLine.textLength);
140
          newLines.push(newLine);
141
          runLength = 0;
142
        }        
143
      }
144
​
145
      for (var i = 0; i < newLines.length; i++) {
111:46 removeEventListener(element: any, type: string, listener: (event: Event) => void): void